package apis

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"yxs-mall/app/mall/pojo/searchcond"
	"yxs-mall/app/mall/service"
	"yxs-mall/common/api"
)

type MallProduct struct {
	api.Api
}

func (e MallProduct) GetProduct(c *gin.Context) {

	s := service.Product{}
	s.Make(c)
	var cond searchcond.ProductSearchCond
	err := c.ShouldBindJSON(&cond)
	if err != nil {
		c.AbortWithStatusJSON(http.StatusOK, api.Error("参数解析错误"))
		return
	}
	result := s.GetProductList(&cond)
	c.AbortWithStatusJSON(http.StatusOK, api.Ok(result))
}

type Product struct {
	Id    int    `json:"id"`
	Title string `json:"title"`
}
